package com.ndhutu.ee.util.dwz.tiny;

import com.ndhutu.ee.util.http.OKHttpUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author AppiJ
 * @Date 2020/5/7 15:32
 */
public class ShortUrlUtil {

    final static String CREATE_API = "http://tinyurl.com/api-create.php";

    /**
     * 创建短链接
     * @Author AppiJ
     * @Date 2020/5/7 15:34
     * @param
     * @return
     */
    public static  String createShortUrl(String longUrl) throws Exception{

        Map<String, String> params = new HashMap<String, String>();
        params.put("url", longUrl);

        String resultJson = OKHttpUtil.get(CREATE_API, params);

        return resultJson;
    }

    public static void main(String[] args) {
        try {
            System.out.println(createShortUrl("http://share.pp.51cyhy.com/download/index.html?channelCode=499778"));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
